package com.crm.controller.hy;

import com.crm.utils.R;
import com.crm.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 数据统计
 */
@Api(value = "数据统计",tags = "数据统计api")
@Controller
@RequestMapping("/dataStatistics")
public class DataStatisticsController {
    R r=new R();

    @RequestMapping(value = "/overview", method = RequestMethod.GET)
    @ApiOperation(value = "系统概括", notes = "系统概括", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R overview(){
        List<DataStatisticsVo> list=new ArrayList<>();
        DataStatisticsVo map24=new DataStatisticsVo("客户管理","联系人","跟单管理","订单管理","合同管理","售后管理");
        DataStatisticsVo map07=new DataStatisticsVo("客户管理","联系人","跟单管理","订单管理","合同管理","售后管理");
        DataStatisticsVo map30=new DataStatisticsVo("客户管理","联系人","跟单管理","订单管理","合同管理","售后管理");
        DataStatisticsVo count=new DataStatisticsVo("客户管理","联系人","跟单管理","订单管理","合同管理","售后管理");

        list.add(map24);
        list.add(map07);
        list.add(map30);
        list.add(count);
        return r.okR(list);
    }

//    select deptId,count(*) from emp GROUP BY deptId

    @RequestMapping(value = "/analysis", method = RequestMethod.GET)
    @ApiOperation(value = "客户分析", notes = "客户分析", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R analysis(){
        AnalysisVo analysisVo=new AnalysisVo();
        //客户类型统计
        List<DataStatisticsVo> list=new ArrayList<>();
        DataStatisticsVo dataStatisticsVo=new DataStatisticsVo("潜在客户","20");
        list.add(dataStatisticsVo);

        analysisVo.setList(list);


//        客户级别统计
        List<DataStatisticsVo> list1=new ArrayList<>();
        dataStatisticsVo=new DataStatisticsVo("vip","20");
        list1.add(dataStatisticsVo);

        analysisVo.setList1(list1);


//        客户来源统计
        List<DataStatisticsVo> list2=new ArrayList<>();
        dataStatisticsVo=new DataStatisticsVo("朋友介绍","20");
        list2.add(dataStatisticsVo);

        analysisVo.setList2(list2);

//        所属行业
        List<DataStatisticsVo> list3=new ArrayList<>();
        dataStatisticsVo=new DataStatisticsVo("农业","20");
        list3.add(dataStatisticsVo);

        analysisVo.setList3(list3);

//        客户省份分布
        List<DataStatisticsVo> list4=new ArrayList<>();
        dataStatisticsVo=new DataStatisticsVo("海南","20");
        list4.add(dataStatisticsVo);

        analysisVo.setList4(list4);

//        客户产品
        List<DataStatisticsVo> list5=new ArrayList<>();
        dataStatisticsVo=new DataStatisticsVo("未知","20");
        list5.add(dataStatisticsVo);

        analysisVo.setList5(list5);


        return r.okR(analysisVo);
    }

    @RequestMapping(value = "/analysisBydate", method = RequestMethod.GET)
    @ApiOperation(value = "通过时间查找客户分析", notes = "通过时间查找客户分析", httpMethod = "GET", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dateF", value = "日期区间前", paramType = "query", dataType = "date", required = true),
            @ApiImplicitParam(name = "dateL", value = "日期区间后", paramType = "query", dataType = "date", required = true)
    })
    @ResponseBody
    public R analysisBydate(Date dateF,Date dateL){
        AnalysisVo analysisVo=new AnalysisVo();
        //客户类型统计
        List<DataStatisticsVo> list=new ArrayList<>();
        DataStatisticsVo dataStatisticsVo=new DataStatisticsVo("潜在客户","20");
        list.add(dataStatisticsVo);

        analysisVo.setList(list);


//        客户级别统计
        List<DataStatisticsVo> list1=new ArrayList<>();
        dataStatisticsVo=new DataStatisticsVo("vip","20");
        list1.add(dataStatisticsVo);

        analysisVo.setList1(list1);


//        客户来源统计
        List<DataStatisticsVo> list2=new ArrayList<>();
        dataStatisticsVo=new DataStatisticsVo("朋友介绍","20");
        list2.add(dataStatisticsVo);

        analysisVo.setList2(list2);

//        所属行业
        List<DataStatisticsVo> list3=new ArrayList<>();
        dataStatisticsVo=new DataStatisticsVo("农业","20");
        list3.add(dataStatisticsVo);

        analysisVo.setList3(list3);

//        客户省份分布
        List<DataStatisticsVo> list4=new ArrayList<>();
        dataStatisticsVo=new DataStatisticsVo("海南","20");
        list4.add(dataStatisticsVo);

        analysisVo.setList4(list4);

//        客户产品
        List<DataStatisticsVo> list5=new ArrayList<>();
        dataStatisticsVo=new DataStatisticsVo("未知","20");
        list5.add(dataStatisticsVo);

        analysisVo.setList5(list5);

        return r.okR(analysisVo);
    }

    @RequestMapping(value = "/statisticsByEmp", method = RequestMethod.GET)
    @ApiOperation(value = "跟单统计-按员工", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R statisticsByEmp(){
        List<DataStatisticsVo> list=new ArrayList<>();
        DataStatisticsVo map=new DataStatisticsVo("员工名","数量");
        list.add(map);
        return r.okR(list);
    }

    @RequestMapping(value = "/statisticsByDept", method = RequestMethod.GET)
    @ApiOperation(value = "跟单统计-按部门", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R statisticsByDept(){
        List<DataStatisticsVo> list=new ArrayList<>();
        DataStatisticsVo map=new DataStatisticsVo("部门名","数量");
        list.add(map);
        return r.okR(list);
    }

    @RequestMapping(value = "/orderStatisticsByEmp", method = RequestMethod.GET)
    @ApiOperation(value = "订单统计-按员工", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R orderStatisticsByEmp(){
        List<DataStatisticsVo> list=new ArrayList<>();
        DataStatisticsVo map=new DataStatisticsVo("员工名","数量");
        list.add(map);
        return r.okR(list);
    }

    @RequestMapping(value = "/orderStatisticsByDept", method = RequestMethod.GET)
    @ApiOperation(value = "订单统计-按部门", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R orderStatisticsByDept(){
        List<DataStatisticsVo> list=new ArrayList<>();
        DataStatisticsVo map=new DataStatisticsVo("部门名","数量");
        list.add(map);
        return r.okR(list);
    }

    @RequestMapping(value = "/aStatisticsByEmp", method = RequestMethod.GET)
    @ApiOperation(value = "合同统计-按员工", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R aStatisticsByEmp(){
        List<DataStatisticsVo> list=new ArrayList<>();
        DataStatisticsVo map=new DataStatisticsVo("员工名","数量");
        list.add(map);
        return r.okR(list);
    }

    @RequestMapping(value = "/aStatisticsByDept", method = RequestMethod.GET)
    @ApiOperation(value = "合同统计-按部门", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R aStatisticsByDept(){
        List<DataStatisticsVo> list=new ArrayList<>();
        DataStatisticsVo map=new DataStatisticsVo("部门名","数量");
        list.add(map);
        return r.okR(list);
    }

    @RequestMapping(value = "/afterStatisticsByEmp", method = RequestMethod.GET)
    @ApiOperation(value = "售后统计-按员工", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R afterStatisticsByEmp(){
        List<DataStatisticsVo> list=new ArrayList<>();
        DataStatisticsVo map=new DataStatisticsVo("员工名","数量");
        list.add(map);
        return r.okR(list);
    }

    @RequestMapping(value = "/afterStatisticsByDept", method = RequestMethod.GET)
    @ApiOperation(value = "售后统计-按部门", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R afterStatisticsByDept(){
        List<DataStatisticsVo> list=new ArrayList<>();
        DataStatisticsVo map=new DataStatisticsVo("部门名","数量");
        list.add(map);
        return r.okR(list);
    }

    @RequestMapping(value = "/annualCurve", method = RequestMethod.GET)
    @ApiOperation(value = "年度曲线", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R annualCurve(){
        List<DataStatisticsVo> list=new ArrayList<>();
        DataStatisticsVo map=new DataStatisticsVo("部门名","数量");
        list.add(map);
        return r.okR(list);
    }

    @RequestMapping(value = "/detailedByEmp", method = RequestMethod.GET)
    @ApiOperation(value = "详细统计-按员工", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R detailedByEmp(){
        List<DetailedVo> list=new ArrayList<>();
        DetailedVo detailedVo=new DetailedVo("张三",2,3,4,5,6,7,8,9);
        list.add(detailedVo);
        return r.okR(list);
    }
    @RequestMapping(value = "/detailedByDept", method = RequestMethod.GET)
    @ApiOperation(value = "详细数据-按部门", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R detailedByDept(){
        List<DetailedVo> list=new ArrayList<>();
        DetailedVo detailedVo=new DetailedVo("业务一部",2,3,4,5,6,7,8,9);
        list.add(detailedVo);
        return r.okR(list);
    }
    @RequestMapping(value = "/commission", method = RequestMethod.GET)
    @ApiOperation(value = "订单提成", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R commission(){
        List<CommissionVo> list=new ArrayList<>();
        CommissionVo commissionVo=new CommissionVo();
        list.add(commissionVo);
        return r.okR(list);
    }
    @RequestMapping(value = "/commissionByTime", method = RequestMethod.GET)
    @ApiOperation(value = "订单提成-按时间查", httpMethod = "GET", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dateF", value = "日期区间前", paramType = "query", dataType = "date", required = true),
            @ApiImplicitParam(name = "dateL", value = "日期区间后", paramType = "query", dataType = "date", required = true)
    })
    @ResponseBody
    public R commissionByTime(){
        List<CommissionVo> list=new ArrayList<>();
        CommissionVo commissionVo=new CommissionVo();
        list.add(commissionVo);
        return r.okR(list);
    }
}
